package logic

import (
	"context"
	"github.com/zeromicro/go-zero/core/logx"
	"group-card/model/entity"
	"group-card/rpc/card/cardclient"
	"group-card/rpc/card/internal/svc"
)

type SkinUpdateLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewSkinUpdateLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SkinUpdateLogic {
	return &SkinUpdateLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *SkinUpdateLogic) SkinUpdate(in *cardclient.SkinUpdateRequest) (*cardclient.SkinUpdateResponse, error) {
	data := entity.CardSkinReq{
		Id:         in.Id,
		Name:       in.Name,
		FaceValue:  in.FaceValue,
		Colour:     in.Colour,
		CustomerId: in.CustomerId,
		Type:       in.Type,
		Status:     in.Status,
		Image:      in.Image,
		AdminId:    in.AdminId,
	}

	var ctx context.Context
	err := l.svcCtx.SkinModel.Update(ctx, &data)

	if err != nil {
		return nil, err
	}

	return &cardclient.SkinUpdateResponse{}, nil
}
